package 早晨练习0420

import java.io.File
import scala.io.Source
import scala.language.implicitConversions

/**
 * 隐式转换练习
 */

// 隐式的增强File类的方法
class RichFile(val from: File) {
  def read = Source.fromFile(from.getPath).mkString
}

object RichFile {
  implicit def file2RichFile(from: File): RichFile = new RichFile(from)
}


object Scala_implicit {
  def main(args: Array[String]): Unit = {
    // 导入隐式转换
    import RichFile._
    println(new File("file/0419/a.txt").read)
  }
}
